using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Blog.IService;
using SqlSugar;
using Blog.IRepository;
using System.Linq.Expressions;

namespace Blog.Service
{
    public class BaseService<T> :IBaseService<T> where T : class, new()
    {
        protected IBaseRepository<T> _iBaseRepository;
        public async Task<bool> CreateAsync(T t)
        {
            return await _iBaseRepository.CreateAsync(t);
        }

        public async Task<bool> DeleteAsync(int id)
        {
            return await _iBaseRepository.DeleteAsync(id);
        }

        public async Task<bool> EditAsync(T t)
        {
            return await _iBaseRepository.EditAsync(t);
        }

        public async Task<T> FindAsync(int id)
        {
            return await _iBaseRepository.FindAsync(id);
        }

        public async Task<T> FindAsync(Expression<Func<T, bool>> func)
        {
            return await _iBaseRepository.FindAsync(func);
        }

        public async Task<List<T>> QueryAsync()
        {
            return await _iBaseRepository.QueryAsync();
        }

        public async Task<List<T>> QueryAsync(Expression<Func<T, bool>> func)
        {
            return await _iBaseRepository.QueryAsync(func);
        }

        public async Task<List<T>> QueryAsync(int page, int size, RefAsync<int> total)
        {
            return await _iBaseRepository.QueryAsync(page, size, total);
        }

        public async Task<List<T>> QueryAsync(Expression<Func<T, bool>> func, int page, int size, RefAsync<int> total)
        {
            return await _iBaseRepository.QueryAsync(func, page, size, total);
        }
    }
}